/*
 * AbstractPlot.hpp
 *
 * Copyright 2012 Pieter Agten
 *
 * This file is part of tltgen.
 *
 * tltgen is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * tltgen is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with tltgen.  If not, see <http://www.gnu.org/licenses/>.
 */

/**
 * @file   AbstractPlot.hpp
 * @author Pieter Agten (pieter.agten@gmail.com)
 * @date   7 jan 2013
 */

#ifndef ABSTRACTPLOT_HPP
#define ABSTRACTPLOT_HPP

#include "wxPLplotwindow.h"

#include <boost/lexical_cast.hpp>
#include <boost/tuple/tuple.hpp>
#include <boost/signals2.hpp>

#include "Plot.hpp"

using boost::tuple;

namespace tltgen {

  class AbstractPlot : public Plot {
  public:
    virtual ~AbstractPlot() = 0;

    virtual std::string getTitle() const = 0;

    virtual unsigned int getNbDatasets() const = 0;
    virtual std::string getDatasetName(unsigned int i) const = 0;
    virtual void plotViewport(wxPLplotstream *pls) = 0;
    virtual void plotDataset(wxPLplotstream *pls, unsigned int i) = 0;

    virtual tuple<PLFLT, PLFLT> getXBoundsAuto() const = 0;
    virtual tuple<PLFLT, PLFLT> getYBoundsAuto() const = 0;

    virtual bool isValidDatasetIndex(unsigned int i) const;
    virtual tuple<PLFLT, PLFLT> getXBounds() const;
    virtual bool isValidXBounds(PLFLT min, PLFLT max) const;
    virtual void setXBounds(PLFLT min, PLFLT max, bool signal = true);
    virtual void setXBoundsAuto(bool signal = true);
    virtual bool isXBoundsAuto() const;
    virtual tuple<PLFLT, PLFLT> getYBounds() const;
    virtual bool isValidYBounds(PLFLT min, PLFLT max) const;
    virtual void setYBounds(PLFLT min, PLFLT max, bool signal = true);
    virtual void setYBoundsAuto(bool signal = true);
    virtual bool isYBoundsAuto() const;

    virtual boost::signals2::connection connectDataChangedObserver(const DataChangedSlot &slot);
    virtual boost::signals2::connection connectNbDatasetsChangedObserver(const NbDatasetsChangedSlot &slot);

  protected:
    DataChangedSignal signalDataChanged;
    NbDatasetsChangedSignal signalNbDatasetsChanged;
    PLFLT xmin, xmax;
    bool xBoundsAuto;
    PLFLT ymin, ymax;
    bool yBoundsAuto;
  };

}

#endif
